/*
PearReview - The peer review assistant.
Copyright (C) 2009  Dimitrij Pankratz, Anton Musichin
http://www.pearreview.com, info@pearreview.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

package com.pearreview.ui;

import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;

import javax.swing.JToolBar;

public class PearToolBar extends JToolBar {
	private static final long serialVersionUID = 464550115227113024L;
	private Color startColor = new Color(0xd6d6d6);
	private Color endColor = new Color(0xa9a9a9);
	
	/*
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		
		Graphics gcopy = g.create();
		gcopy.setColor(new Color(0xd6, 0xd6, 0xd6));
		gcopy.fillRect(0, 0, this.getWidth(), this.getHeight());
		gcopy.dispose();
	}
	*/
	@Override
	protected void paintComponent(Graphics g) {
		//TODO clean code
		/*
		Graphics gcopy = g.create();
		gcopy.setColor(new Color(0xd6, 0xd6, 0xd6));
		gcopy.fillRect(0, 0, this.getWidth(), this.getHeight());
		gcopy.dispose();
		*/
		
		Graphics2D g2 = (Graphics2D) g;
		super.paintComponent(g);
		GradientPaint p;
		p = new GradientPaint(0, 0, startColor,
		0, getHeight(), endColor);
		Paint oldPaint = g2.getPaint();
		g2.setPaint(p);
		g2.fillRect(0, 0, getWidth(), getHeight());
		g2.setPaint(oldPaint);
    }
}
